home *** CD-ROM | disk | FTP | other *** search
- /* PSDPort.c */
- /* Copyright 1992, Gary D. McGath */
-
- /* Routines for monitoring and handling changes in the GrafPort */
-
-
- /* Globals */
-
- extern void OutputString(char *str, int theFile);
-
- void psdSetPenPat(void);
- void psdSetFillPat(void);
- void OutputGray(double lev);
-
- static void psdSetPat(unsigned char *p1);
-
- extern int thePSFile;
- extern Rect gPSClipRect;
-
- double gblGray; /* last gray level output */
- int gblFont;
- int gblSize;
-
-
- /* Set up defaults for the port. */
- void psdInitPort(GrafPtr itsPort)
- {
- itsPort->pnSize.h = 1;
- itsPort->pnSize.v = 1;
- gblGray = -1;
- gblFont = -1;
- gblSize = -1;
- }
-
- /* Output PostScript code to match the new pattern. "Real" code should
- set up a pattern fill; this one sets the color to black, white, or 50%
- gray depending on the pattern. */
- void psdSetPenPat()
- {
- psdSetPat((unsigned char *)&thePort->pnPat);
- }
-
- void psdSetFillPat()
- {
- psdSetPat((unsigned char *)&thePort->fillPat);
- }
-
- static void psdSetPat(unsigned char *p1)
- {
- int allWhite = 1;
- int allBlack = 1;
- register int i;
- for (i = 1; i < 8; i++) {
- if (*p1 != 0XFF)
- allBlack = 0;
- if (*p1++ != 0)
- allWhite = 0;
- }
- if (allWhite)
- OutputGray(1.0);
- else if (allBlack)
- OutputGray(0.0);
- else OutputGray(0.5);
- }
-
-
-
- /* output a gray level, only if it's different from the previous one */
- void OutputGray(double lev)
- {
- if (lev != gblGray) {
- OutputDouble(lev,thePSFile);
- OutputString("setgray\r",thePSFile);
- gblGray = lev;
- }
- }
-
-
-
-